package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.Dianpu;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Jubaoguanli;
import com.ruoyi.system.service.IJubaoguanliService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 举报管理Controller
 * 
 * @author cjq
 * @date 2024-08-14
 */
@RestController
@RequestMapping("/system/jubaoguanli")
public class JubaoguanliController extends BaseController
{
    @Autowired
    private IJubaoguanliService jubaoguanliService;


    /**
     * 查询举报管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:jubaoguanli:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(Jubaoguanli jubaoguanli)
//    {
//        System.out.println("======================");
//        System.out.println(jubaoguanli);
//        System.out.println("======================");
//        startPage();
//        List<Jubaoguanli> list = jubaoguanliService.selectJubaoguanliList(jubaoguanli);
//        return getDataTable(list);
//    }

    @PreAuthorize("@ss.hasPermi('system:jubaoguanli:list')")
    @RequestMapping("/list")
    public TableDataInfo list(@RequestBody Map<String,Object> map)
    {
        System.out.println("======================");
        System.out.println(map);
        System.out.println("======================");
        startPage();
        List<Jubaoguanli> list = jubaoguanliService.selectJubaoguanliList(map);
        return getDataTable(list);
    }

    /**
     * 导出举报管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:jubaoguanli:export')")
    @Log(title = "举报管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Map<String,Object> map)
    {
        List<Jubaoguanli> list = jubaoguanliService.selectJubaoguanliList(map);
        ExcelUtil<Jubaoguanli> util = new ExcelUtil<Jubaoguanli>(Jubaoguanli.class);
        util.exportExcel(response, list, "举报管理数据");
    }

    /**
     * 获取举报管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jubaoguanli:query')")
    @GetMapping(value = "/{jbglId}")
    public AjaxResult getInfo(@PathVariable("jbglId") Long jbglId)
    {
        return success(jubaoguanliService.selectJubaoguanliByJbglId(jbglId));
    }

    /**
     * 新增举报管理
     */
    @PreAuthorize("@ss.hasPermi('system:jubaoguanli:add')")
    @Log(title = "举报管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jubaoguanli jubaoguanli)
    {
        return toAjax(jubaoguanliService.insertJubaoguanli(jubaoguanli));
    }

    /**
     * 修改举报管理
     */
    @PreAuthorize("@ss.hasPermi('system:jubaoguanli:edit')")
    @Log(title = "举报管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jubaoguanli jubaoguanli)
    {
        return toAjax(jubaoguanliService.updateJubaoguanli(jubaoguanli));
    }

    /**
     * 删除举报管理
     */
    @PreAuthorize("@ss.hasPermi('system:jubaoguanli:remove')")
    @Log(title = "举报管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jbglIds}")
    public AjaxResult remove(@PathVariable Long[] jbglIds)
    {
        return toAjax(jubaoguanliService.deleteJubaoguanliByJbglIds(jbglIds));
    }
}
